package com.itheima.zuoye2.zuoye1;

import lombok.Data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateUtils {
    //方法将日期转换为字符串
    public static String dateToString(LocalDate Data1) {
        DateTimeFormatter df =DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return df.format(Data1);
    }
    //方法将字符串转换为日期
    public static LocalDate stringToDate(String  String1) {
        DateTimeFormatter  df =DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return LocalDate.parse(String1,df);
    }
}
